<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>v-for添加key作用</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id ="app"> 
    <ul>
      <!-- key的主要作用是为了高校的更新虚拟DOM -->
      <!-- 
        使用key来给每个节点做一个唯一标识：
          Diff算法就可以正确的识别此节点
          找到正确的位置区插入新的节点
       -->
      <li v-for="item in letters" :key='item'>{{ item }} </li>
    </ul>

  </div>

  <script>
   var vm = new Vue({
    el: '#app',
    data: {
      letters: ['A', 'B', 'C', 'D', 'E','C'],
      subStr: 20210102123305
    },
    methods: {
      
    }
   });
  </script>
</body>

</html>